﻿function getCurrentLocation() {
    try {
        navigator.geolocation.getCurrentPosition(showCurrentLocation, errorHandler
        , {
            timeout: 20000,
            maximumAge: 120000
        }
        )
    }
    catch (e) {
        errorHandler();
    }
}

function errorHandler() {
    var latLong = new UserGeolocation();
    latLong.getCurrentLocationByIpAddress();
}

function showCurrentLocation(position) {
    try {
        var latLong = new UserGeolocation();
        latLong.set_latitude(position.coords.latitude);
        latLong.set_longitude(position.coords.longitude);
        latLong.save2db();
    }
    catch (e) {
        alert(e);
    }
     
}
